package{
    import caurina.transitions.Tweener;
    
    import flash.display.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.text.*;
	
	[SWF(width="800",height="600", backgroundColor="#ffffff",frameRate="30")]
    public class Foo extends Sprite{
        private var bd:BitmapData;
        private var space:int=10;
        public function Foo():void{
            var tf:TextField = new TextField();
            tf.textColor = 0x000000;
            tf.text = "xien~~♡\n i love you!";
            tf.autoSize = "left";
    		//文本 draw成BitmapData
            bd = new BitmapData(tf.width, tf.height, false, 0x3399ff);
            bd.draw(tf);
    		//添加滤镜
            bd.applyFilter(bd, bd.rect, new Point(), new BlurFilter(2,2,2));
            bd.draw(tf);
            //addChild(new Bitmap(bd));
   
    		//循环排列
            for(var i:int = 0; i < bd.width; i++){
                for(var j:int = 0; j < bd.height; j++){
                    Tweener.addTween(
                        randomize(addChild(new Circle(bd.getPixel(i, j)))), //getPixel（）用来按照位置获取颜色
                        {
     					   //排列
                            x: (stage.stageWidth-tf.width*space)/2+(i * space),
                            y: (stage.stageHeight-tf.height*space)/2+(j * space),
                            alpha: 1,
                            delay: (i+j) * .03 * Math.random(),//延时
                            time: 1
                        }
                    );
                }
            }
        }
   		//仿粒子
        /**
         *在1000，400这个区域内，随机定位显示对象的坐标和透明度 
         * @param d
         * @return 
         * 
         */   		
        private function randomize(d:DisplayObject):DisplayObject{
           d.x = 800 * Math.random();
            d.y = 600 * Math.random();
            d.alpha = 0;
            return d;
        }
    }
}


import flash.display.Sprite;
//元素小球
class Circle extends Sprite{
    public function Circle(color:uint):void{
        graphics.beginFill(color);
        graphics.drawCircle(0, 0, 6);
        graphics.endFill();
    }
}